<template>
    <div>
        <el-row>
            <el-col :span="4" style="height: 150px;  background-color: rgb(25, 211, 25);">
                <div class="grid-content bg-purple ">
                    <i class="el-icon-money myicon"></i>
                    <div class="mytext">
                        <p>今日订单总额(元)</p>
                        <animate-number v-if="number[0]" class="grid-num" :from="1" :to="number[0]" duration="1000"></animate-number>
                    </div>
                </div>
            </el-col>
            <el-col :span="4" style="height: 150px;  background-color: rgb(146, 25, 211);">
                <div class="grid-content bg-purple ">
                    <i class="el-icon-s-order myicon"></i>
                    <div class="mytext">
                        <p>今日订单总数</p>
                        <animate-number v-if="number[1]" class="grid-num" :from="1" :to="number[1]" duration="1000"></animate-number>
                    </div>
                </div>
            </el-col>
            <el-col :span="4" style="height: 150px;  background-color: rgb(25, 71, 211);">
                <div class="grid-content bg-purple ">
                    <i class="el-icon-user-solid myicon"></i>
                    <div class=" mytext">
                        <p>今日新增用户数</p>
                        <animate-number v-if="number[2]" class="grid-num" :from="1" :to="number[2]" duration="1000"></animate-number>
                    </div>
                </div>
            </el-col>
            <el-col :span="4" style="height: 150px;  background-color: rgb(211, 195, 25);">
                <div class="grid-content bg-purple ">
                    <i class="el-icon-s-custom myicon"></i>
                    <div class="mytext">
                        <p>今日新增商户</p>
                        <animate-number v-if="number[3]" class="grid-num" :from="1" :to="number[3]" duration="1000"></animate-number>
                    </div>
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { selectIndent } from '@/api/dashboard'
export default {
    props: ['childtime'],
    data() {
        return {
            endtime: '',
            number:[]
        }
    },
    mounted() {
        this.endtime = this.childtime
        this.handleechart1()
    },
    methods: {
        async handleechart1() {
            let list = ['/selectIndentmonByTime', '/selectIndentcountByTime', '/selectUserByTime', '/selectMerchantByTime']
            for(let i=0;i<list.length;i++){
            // var dayjs = require('dayjs')

            if (this.endtime) {
                this.endtime = this.$day(this.endtime).format('YYYY-MM-DD')
            } else {
                this.endtime = this.$day(new Date()).format('YYYY-MM-DD')
            }
            let obj = {
                endtime: this.endtime
            }
            const param = new URLSearchParams(obj)
            const res = await selectIndent(list[i], param)
            // console.log(res.data);
            this.number.push(res.data)
            }
        }
    }
}

</script>

<style lang="scss" scoped></style>